package com.proj.service.impl;

import com.proj.bean.Order;
import com.proj.bean.Orderinfo;
import com.proj.bean.Useraddress;
import com.proj.dao.OrderDao;
import com.proj.service.IOrderService;
import com.proj.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;

@Service
public class OrderService implements IOrderService {

    @Autowired
    OrderDao orderDao;

    @Transactional      //确保事务
    @Override
    public int addOrder(Order order) {
        //获取商品数据
        //计算总价格
        //封装订单
        //保存订单  获取订单id（自增长）
        //封装订单明细
        //获取商品地址
        //处理地址
        //封装地址
        //删除购物车中的数据
        return orderDao.addOrder(order);
    }

    @Override
    public int addOrderInfo(Order order) {
        return orderDao.addOrderInfo(order);
    }

    @Override
    public int addOrderAddress(Order order) {
        return orderDao.addOrderAddress(order);
    }

    @Override
    public int OrderDelCart(int userid) {
        return orderDao.OrderDelCart(userid);
    }

    @Override
    public List<Order> easyOrder(int userid) {
        return orderDao.easyOrder(userid);
    }

    @Override
    public List<Order> allOrder(Page page, String text) {
        return orderDao.allOrder(page,text);
    }

    @Override
    public int allOrdercount(String text){
        return orderDao.allOrdercount(text);
    }

    @Override
    public Order getMoneyByOrderid(int orderid) {
        return orderDao.getMoneyByOrderid(orderid);
    }

    @Override
    public int zhifu(int orderid) {
        return orderDao.zhifu(orderid);
    }

    @Override
    public int send(int orderid) {
        return orderDao.send(orderid);
    }

    @Override
    public int shouhuo(int orderid) {
        return orderDao.shouhuo(orderid);
    }

    @Override
    public int jieshu(int orderid) {
        return orderDao.jieshu(orderid);
    }


    @Override
    public Useraddress getAddress(int userid) {
        return orderDao.getAddress(userid);
    }

    @Override
    public int overdueOrdersCancelled() {
        return orderDao.overdueOrdersCancelled();
    }

    @Override
    public List<Orderinfo> roseinfos() {
        return orderDao.roseinfos();
    }


}
